/*
 * FileName: DailyController.java
 *
 */
package com.mrc.ak.daily.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.mrc.ak.daily.service.DailyInfoService;
import com.mrc.core.base.CommonController;
import com.mrc.core.base.PageDatas;
import com.mrc.core.model.SysUser;
import com.mrc.core.service.SysUserService;

/**
 * <p>
 * Description: 员工 日报处理
 * </p>
 *
 * @author Mrc
 * @version 4.1

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2016-12-22 上午10:05:15          Mrc        4.1         To create
 * </p>
 *
 * @since 
 * @see     
 */
@Controller
@RequestMapping(value = "/StaffDailyController.do")
public class DailyInfoController extends CommonController {

    @Autowired
    private DailyInfoService dailyInfoService;
    @Autowired
    private SysUserService sysUserService;

    /**
     * 员工保存日报
     * @param dailyContent 内容
     * @param type 分类
     * @param dealStatus 处理状态
     * @param remark 备注
     * @return
     */
    @ResponseBody
    @RequestMapping(params = "method=saveDaily")
    public Map<String, Object> saveDaily(HttpServletRequest request, String dailyContent, Integer type, Integer dealStatus, String remark) {
        Map<String, Object> result = super.getReturnResult();
        if (StringUtils.isEmpty(dailyContent)) {
            result.put("code", CommonController.STATUS_FAILED);
            result.put("message", "没有日报内容，不进行保存");
            return result;
        }
        SysUser user = sysUserService.getCurrentUser(request);
        dailyInfoService.saveDaily(user, dailyContent, type, dealStatus, remark);
        return result;
    }

    /**
     * 按照条件查询日报
     * @param request
     * @param date 日期    2016-12-22 或者  2016-12-21至2016-12-22
     * @param verifyStatus 审核状态
     * @param type 分类
     * @return
     */
    @ResponseBody
    @RequestMapping(params = "method=queryDaily")
    public PageDatas queryDaily(String date, String verifyStatus, Integer type, Integer pageNo, Integer pageSize) {
        PageDatas list = dailyInfoService.query(date, verifyStatus, type, pageNo, pageSize);
        return list;
    }

}
